package com.aop.annotation;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Method;

public class TextInterceptor implements MethodInterceptor {

    private static final  Logger LOGGER = LoggerFactory.getLogger(TextAnnotation.class);

    @Override
    public Object invoke(final MethodInvocation methodInvocation) throws Throwable {
        Method method = methodInvocation.getMethod();
        if (method.isAnnotationPresent(TextAnnotation.class)) {
            TextAnnotation annotation = method.getAnnotation(TextAnnotation.class);
            LOGGER.info("==============annotation:{}==============",annotation);
        }
        return methodInvocation.proceed();
    }
}
